﻿@model List<BDShop.Entities.ProductCacheComplex>
@using BDShop.Configuration
@using BDShop.Library.Extensions
@using BDShop.Utilities.Managers

<ul class="slides">
    @foreach (var product in Model)
    {
        string[] categoryDefinition = null;
        if (!string.IsNullOrEmpty(product.CategoryDefinition))
        {
            categoryDefinition = product.CategoryDefinition.Split('|')[0].Split('#');
        }
        var url = UrlManager.ProductDetailUrl(product.ID, product.Name, categoryDefinition);
        <li>
            <div class="slide-inner">
                <div class="image">
                    <a href="@url">
                        <img class="lazy" data-original="@Path.Combine(BDShopConfiguration.Storage.MainImagePath, product.MainImage)" src="@Path.Combine(BDShopConfiguration.Storage.MainImagePath, product.MainImage)" alt="@product.Name" /></a>
                </div>
                <div class="name"><a href="@url">@product.Name</a></div>
                <div class="price">
                    @if (product.DiscountPrice == 0)
                    {
                        <span class="price-new">@product.Price.ToCurrencyString(false, true)</span> 
                    }
                    else
                    {
                        <span class="price-old">@product.MarketPrice.ToCurrencyString(false, true)</span> <span class="price-new">@product.Price.ToCurrencyString(false, true)</span> 
                    }
                </div>
                <div class="cart">
                    <input type="button" value="Mua hàng" class="button" onclick="window.location.href='@url'" />
                </div>
                <div class="clear"></div>
            </div>
        </li>
    }
</ul>
